/**
 * 企业更改信息审核
 */
/**
 * 数据源
 * 
 * @class xxggsh_gridpanel_store
 * @extends Ext.data.Store
 */
xxggsh_gridpanel_store = Ext.extend(Ext.data.Store, {
	constructor : function() {
		xxggsh_gridpanel_store.superclass.constructor.call(this, {
			proxy : new Ext.data.HttpProxy({
						url : 'xxggsh/getallchangedenterpriseinfo.action?cityid='
								+ user_city,
						method : 'post'
					}),
			autoLoad : true,
			reader : new Ext.data.JsonReader({
						fields : ['id', 'user_id', 'editable',
								'enterprise_state', 'enterprise_style',
								'enterprise_expe_year', 'enterprise_demo_year',
								'enterprise_is_nationalInnovation',
								'enterprise_updateinfo',
								'enterprise_updatestatus', 'enterprise_name',
								'enterprise_address',
								'enterprise_corporate_code', 'enterprise_city',
								'enterprise_postcode',
								'enterprise_corporateRepresentative',
								'enterprise_telephone',
								'enterprise_person_incharge',
								'enterprise_phone_incharge',
								'enterprise_eco_type', 'enterprise_org_type',
								'enterprise_largest_sharehoder',
								'enterprise_largest_share',
								'enterprise_listed_type',
								'enterprise_science_type',
								'enterprise_industry_code',
								'enterprise_highsci_authenticate_year',
								'enterprise_highsci_authenticate_department',
								'enterprise_highsci_field',
								'enterprise_credit_degree',
								'enterprise_business_field',
								'enterprise_field_closeness',
								'enterprise_major_business',
								'enterprise_staff_count',
								'enterprise_staff_collegedegree_count',
								'enterprise_research_staff_count',
								'enterprise_senior_technician_count', 'isCheck']
					})
		})
	}
});
/**
 * 显示面板
 * 
 * @class changed_enterpriseinfo_gridpanel
 * @extends Ext.grid.GridPanel
 */
arrsm = new Ext.grid.RowSelectionModel({
			singleSelect : true
		});// 选择模型
changed_enterpriseinfo_gridpanel = Ext.extend(Ext.grid.GridPanel, {
	store : null,
	win : null,
	constructor : function() {
		this.store = new xxggsh_gridpanel_store();

		changed_enterpriseinfo_gridpanel.superclass.constructor.call(this, {
					loadMask : {
						msg : '数据加载中...'
					},
					title : '更改信息企业名单',
					iconCls : 'chimouser',
					sm : arrsm,
					frame : true,
					cm : new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),
							{
								header : 'ID',
								width : 160,
								dataIndex : 'enterprise_updateinfo',
								id : 'enterprise_updateinfo',
								hidden : true,
								align : 'center'
							}, {
								header : 'user_id',
								width : 160,
								dataIndex : 'user_id',
								id : 'user_id',
								hidden : true,
								sortable : false,
								align : 'center'
							}, {
								header : '所在城市',
								width : 160,
								dataIndex : 'enterprise_city',
								sortable : false,
								renderer : getCityName,
								align : 'center'
							}, {
								header : '企业名称',
								width : 160,
								dataIndex : 'enterprise_name',
								sortable : false,
								align : 'center'
							}, {
								header : '企业地址',
								width : 160,
								dataIndex : 'enterprise_address',
								sortable : false,
								// renderer:function (value, cellmeta, record,
								// rowIndex, columnIndex, store) {
								// if(value){
								// return "<font color='red'>"+value+"</font>";
								// }
								// },
								align : 'center'
							}, {
								header : '企业法人代表',
								width : 160,
								dataIndex : 'enterprise_corporateRepresentative',
								sortable : false,
								id : 'enterprise_corporateRepresentative',
								align : 'center'
							}]),
					autoExpandColumn : 'enterprise_corporateRepresentative',
					ds : this.store,
					tbar : [{
								text : '查看详情',
								iconCls : 'smlmanage',
								handler : this.checkChangedInfo,
								scope : this
							}]
				})
	},
	checkChangedInfo : function() {
		var ro = this.getSelectionModel().getSelected();
		if (!ro) {
			Ext.Msg.show({
						title : '提示',
						msg : '请选择数据',
						icon : Ext.Msg.ERROR,
						buttons : Ext.Msg.OK
					});
			return;
		}
		var enid = ro.get('enterprise_updateinfo');
		var cfg = {
			id : enid
		};
		this.win = new changedinfostore_gridpanel_win(cfg);
		this.win.on('checkok', function() {
					this.getStore().reload()
				}, this);
		this.win.show(Ext.getDom('west-div'));
	}
});
changedinfostore = Ext.extend(Ext.data.Store, {
			cfg : null,
			constructor : function(_cfg) {
				this.cfg = _cfg;
				changedinfostore.superclass.constructor.call(this, {
							proxy : new Ext.data.HttpProxy({
										url : 'xxggsh/getchangeinfocompare.action?id='
												+ this.cfg.id,
										method : 'post'
									}),
							autoLoad : true,
							reader : new Ext.data.JsonReader({
										fields : ['name', 'frist', 'second']
									})
						})
			}
		});
changedinfostore_gridpanel = Ext.extend(Ext.grid.GridPanel, {
	stroe : null,
	cfg : null,
	constructor : function(_cfg) {
		this.cfg = _cfg;
		this.store = new changedinfostore(this.cfg);
		changedinfostore_gridpanel.superclass.constructor.call(this, {
			loadMask : {
				msg : '数据加载中...'
			},
			// sm : arrsm,
			height : 600,
			frame : true,
			columns : [new Ext.grid.RowNumberer(), {
						header : '名称',
						width : 120,
						dataIndex : 'name',
						sortable : true,
						align : 'center'
					}, {
						header : '初始值',
						width : 120,
						dataIndex : 'frist',
						sortable : true,
						renderer : function(value, cellmeta, record, rowIndex,
								columnIndex, store) {

							return "<font color='blue'>" + value + "</font>";

						},
						align : 'center'
					}, {
						header : '修改值',
						width : 120,
						dataIndex : 'second',
						sortable : true,
						renderer : function(value, cellmeta, record, rowIndex,
								columnIndex, store) {
							if (value) {
								return "<font color='red'>" + value + "</font>";
							}
						},
						align : 'center'
					}]
		});
	}
});
changedinfostore_gridpanel_win = Ext.extend(Ext.Window, {
			cfg : null,
			panel : null,
			constructor : function(_cfg) {
				this.cfg = _cfg;
				this.panel = new changedinfostore_gridpanel(this.cfg);
				changedinfostore_gridpanel_win.superclass.constructor.call(
						this, {
							title : '<font color="red">企业修改信息对比</font>',
							iconCls : 'check_pass',
							width : 390,
							height : 600,
							modal : true,
							defaults : {
								split : true
							},
							items : [this.panel],
							buttons : [{
										text : '通过',
										iconCls : 'accept',
										scope : this,
										handler : this.passCheck
									}, {
										text : '不通过',
										iconCls : 'cmcross',
										scope : this,
										handler : this.notPassCheck
									}]
						});
				this.addEvents('checkok');
			},
			notPassCheck : function() {
				Ext.Ajax.request({
							url : 'xxggsh/notpasschangedinfo.action',
							params : {
								id : this.cfg.id
							},
							success : function(result, request) {
								if (result.responseText == 'ok') {
									Ext.Msg.show({
												title : '提示',
												msg : '成功修改数据',
												icon : Ext.Msg.INFO,
												buttons : Ext.Msg.OK
											});
								}
								
								this.fireEvent('checkok');
								this.hide();
							},
							failure : function() {
							},
							scope : this
						})
			},
			passCheck : function() {
				Ext.Ajax.request({
							url : 'xxggsh/passchangedinfo.action',
							params : {
								id : this.cfg.id
							},
							success : function(result, request) {
								if (result.responseText == 'ok') {
									Ext.Msg.show({
												title : '提示',
												msg : '成功修改数据',
												icon : Ext.Msg.INFO,
												buttons : Ext.Msg.OK
											});
								}
								this.fireEvent('checkok');
								this.hide();							
							},
							failure : function() {
							},
							scope : this
						})
			}
		});
Ext.extend(demo.module, {
			init : function() {
				this.platbody = new changed_enterpriseinfo_gridpanel();
				this.main.add(this.platbody);
				this.main.doLayout();
			}
		});